package com.ruoyi.web.controller.health;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.health.domain.HealthReport;
import com.ruoyi.health.service.IHealthReportService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 报告信息Controller
 *
 * @author rockvan
 * @date 2023-04-10
 */
@Api("报告信息管理")
@RestController
@RequestMapping("/health/healthreportinfo")
public class HealthReportController extends BaseController
{
    @Autowired
    private IHealthReportService healthReportService;

    /**
     * 查询报告信息列表
     */
    @ApiOperation("查询报告信息列表")
    @PreAuthorize("@ss.hasPermi('health:healthreportinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(HealthReport healthReport)
    {
        startPage();
        List<HealthReport> list = healthReportService.selectHealthReportList(healthReport);
        return getDataTable(list);
    }

    /**
     * 导出报告信息列表
     */
    @ApiOperation("导出报告信息列表")
    @PreAuthorize("@ss.hasPermi('health:healthreportinfo:export')")
    @Log(title = "报告信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HealthReport healthReport)
    {
        List<HealthReport> list = healthReportService.selectHealthReportList(healthReport);
        ExcelUtil<HealthReport> util = new ExcelUtil<HealthReport>(HealthReport.class);
        util.exportExcel(response, list, "报告信息数据");
    }

    /**
     * 获取报告信息详细信息
     */
    @ApiOperation("获取报告信息详细信息")
    @ApiImplicitParam(name = "id", value = "物资编号", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
    @PreAuthorize("@ss.hasPermi('health:healthreportinfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(healthReportService.selectHealthReportById(id));
    }

    /**
     * 新增报告信息
     */
    @ApiOperation("新增报告信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "编号", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "username", value = "用户名称", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "type", value = "返程情况", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "img1", value = "健康码", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "img2", value = "行程码", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "img3", value = "核酸报告", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "phoneNumber", value = "手机号", dataType = "String", dataTypeClass = String.class),
    })
    @PreAuthorize("@ss.hasPermi('health:healthreportinfo:add')")
    @Log(title = "报告信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HealthReport healthReport)
    {
        healthReport.setUsername(getUsername());
        healthReport.setDeptId(getDeptId());
        return toAjax(healthReportService.insertHealthReport(healthReport));
    }

    /**
     * 修改报告信息
     */
    @ApiOperation("修改报告信息")
    @PreAuthorize("@ss.hasPermi('health:healthreportinfo:edit')")
    @Log(title = "报告信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HealthReport healthReport)
    {
        return toAjax(healthReportService.updateHealthReport(healthReport));
    }

    /**
     * 删除报告信息
     */
    @ApiOperation("删除报告信息")
    @ApiImplicitParam(name = "ids", value = "编号", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
    @PreAuthorize("@ss.hasPermi('health:healthreportinfo:remove')")
    @Log(title = "报告信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(healthReportService.deleteHealthReportByIds(ids));
    }
}
